package pratise;

public class RemoveDuplicates {
    public int removeDuplicates(int[] nums) {
        if(nums.length == 0) {
            return 0;
        }
        int slow = 1;//有效长度 nums[slow] 表示当前判断是否相同的值
        int fast = 0;//表示当前判断的下标
        while(fast < nums.length) {
            if(nums[slow] == nums[fast]) {
                fast++;
            } else {
                nums[slow++] = nums[fast];
            }
        }
        return slow;
    }

    public static void main(String[] args) {

    }
}
